package java_1_11.interface_test;
class A implements Cloneable{
    int num;
    @Override
    protected A clone() throws CloneNotSupportedException {
        return (A)super.clone();
    }
}
public class B implements Cloneable{
    A a=new A();
    @Override
    protected B clone() throws CloneNotSupportedException {
//        return (B)super.clone();
        B newB=(B)super.clone();
        newB.a=a.clone();//让a也是克隆来的
        return newB;
    }
    public static void main(String[] args) throws CloneNotSupportedException {
        B b1=new B();
        B b2=b1.clone();
        System.out.println(b1==b2);
        System.out.println(b2.a.num);
        b1.a.num=100;
        System.out.println(b2.a.num);
    }
}
